﻿module Sustainalytics.GCCS.Security {

    import Routing = Sustainalytics.Routing;

    export class GCMultiCompanyRouteSecurityService implements Routing.IRouteSecurityService {

        constructor(
            private $q: ng.IQService,
            private GCPermissionsService: GCPermissionsService) {
        }

        validate(security: Routing.RouteSecurity): ng.IPromise<boolean> {
            var ctx = this;

            var valid = ctx.GCPermissionsService.hasMultiCompNC() || ctx.GCPermissionsService.hasMultiCompWL();

            return ctx.$q.when(valid);
        }
    }


    export var gcMultiCompanyRouteSecurityService = 'GCMultiCompanyRouteSecurityService';

    angular.module(gccsSecurityModuleName).service(gcMultiCompanyRouteSecurityService, ['$q', 'GCPermissionsService', GCMultiCompanyRouteSecurityService]);
}